package cn.aitrox.ry.service.config.dao.impl;

import cn.aitrox.ry.common.dao.MapperSqlCallback;
import cn.aitrox.ry.common.dao.impl.BaseDaoImpl;
import cn.aitrox.ry.service.config.dao.DictDao;
import cn.aitrox.ry.service.config.entity.DictEntity;
import cn.aitrox.ry.service.config.mapper.DictMapper;
import cn.aitrox.ry.service.config.po.dict.DictFindInPo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DictDaoImpl extends BaseDaoImpl<DictEntity> implements DictDao {

    @Autowired
    private DictMapper mapper;

    @Override
    public String findMaxCodeByParentId(Integer parentId) {
        return mapper.findMaxCodeByParentId(parentId);
    }

    @Override
    public PageInfo<DictEntity> search(Integer page, Integer pageSize, String orderBy, DictFindInPo dictFindInPo) {
        return super.searchByCustom(page, pageSize, orderBy, new MapperSqlCallback<DictEntity>() {
            @Override
            public List<DictEntity> invoke() {
                return mapper.findByCond(dictFindInPo);
            }
        });
    }
}
